import request from "@/utils/request";
const DASHBOARD_BASE_URL = "/api/admin";
const DashboardAPI = {
  /**
   * 发送验证码
   */
  sendCodeByApp(data: DashboardDialogFormData) {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/sendCodeByApp`,
      method: "post",
      data: data,
    });
  },
  /**
   * 获取密钥
   */
  getAppSecret(data: DashboardDialogFormData) {
    return request<any, AppSecretResult>({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/getAppSecret`,
      method: "post",
      data: data,
    });
  },
  /**
   * 重置密钥
   */
  resetAppSecret(data: DashboardDialogFormData) {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/resetAppSecret`,
      method: "post",
      data: data,
    });
  },
  /**
   * 添加IP白名单
   */
  addIpAddress(data: DashboardDialogFormData) {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/addIpAddress`,
      method: "post",
      data: data,
    });
  },
  /**
   * 移除IP白名单
   */
  removeIpAddress(data: removeIpAddressFormData) {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/removeIpAddress`,
      method: "post",
      data: data,
    });
  },
  /**
   * 设置
   */
  setAppMsgReceive(data: DashboardDialogFormData) {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/setAppMsgReceive`,
      method: "post",
      data: data,
    });
  },
  /**
   * 申请授权
   */
  applyAppAudit() {
    return request({
      url: `${DASHBOARD_BASE_URL}/openPlatform/appData/applyAppAudit`,
      method: "post",
    });
  },
};
export default DashboardAPI;

/** 登录表单数据 */
export interface DashboardDialogFormData {
  /** IP */
  ip: string;
  /** 签名 */
  msgSign: string;
  /** 签名地址 */
  msgUrl: string;
  /** 验证码缓存key */
  captchaKey: string;
  /** 图片验证码 */
  captcha: string;
  /** 手机验证码 */
  code: string;
  /** 手机号 */
  mobile: string;
}
/** 密钥返回 */
export interface AppSecretResult {
  /** 密钥 */
  secret: string;
}
/** 移除提交参数 */
export interface removeIpAddressFormData {
  /** ip */
  ip: string;
}
